<?php
include dirname(dirname(__FILE__)).'/admin-verify.php';
include dirname(__FILE__).'/functions.php';
include_once dirname(dirname(dirname(__FILE__))).'/include/host-base.php';
$_className=addslashes($_GET["className"]);
?>

<html>
	<head>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php'; ?>
		<script type="text/javascript">
		

		$(document).ready(function(){



			$("#class-name").blur(function(){

				var _className=$.trim($(this).val());
				var _preClassName=$.trim($("#pre-class-name").val());
				if(_className==null||_className=='')return;
				if(_className.length<2){

					$("#class-name").parent().parent().addClass("has-error");
					$("#class-name").next().html("商品类型名称长度应大于2").fadeIn();
					$("#add-class-btn").attr("disabled","disabled");

					
					}
				else{
				$.ajax({
					dataType:"text",
					url:'ajax/is-goods-class-exists.php',
					data:{className:_className},
					success:function(data) {
						if(data=='yes'&&_preClassName!=_className) {
							$("#class-name").parent().parent().addClass("has-error");
							$("#class-name").next().html("此商品类型已存在").fadeIn();
							$("#add-class-btn").attr("disabled","disabled");
						} else {
							$("#class-name").parent().parent().removeClass("has-error")
							$("#class-name").next().hide();
							$("#add-class-btn").removeAttr("disabled");
						}
					},
				});

				}
				
				});
				
			$("input").attr("maxlength","16");			
			
			});
	
	
		</script>
		<title>商品类型编辑</title>
	</head>
	<body>
	
		<form class="form-horizontal" role="form" method="post" action="update-goods-class.php">
				 
			<div class="form-group" >
				    <label for="class-name" class="col-sm-2 control-label">商品类型</label>
				    <div class="col-sm-3">
				      <input required  type="text" name="class-name"  value=<?php echo '"'.$_className.'"' ?> class="form-control normal-input" id="class-name" placeholder="商品类别">
				       <p class="help-block" style="display:none"></p>
				       <input type="text"  name="pre-class-name" id="pre-class-name" value=<?php echo '"'.$_className.'"' ?>  style="display: none" />
				    </div>
			</div>	
		
			<div class="form-group">
				    <div class="col-sm-offset-2 col-sm-10">
				      <button type="submit" class="btn btn-primary" id="update-class-btn">修改</button>
				    </div>
			</div>	
	</form>
		
	</body>
</html>